/**
 * redis
 */
const Redis = require('ioredis')
const redis = {
    port: 6379,          // Redis port
    host: 'localhost',   // Redis host
    prefix: 'pon:', //存诸前缀
    ttl: 60 * 60 * 23,  //过期时间   
    family: 4,
    db: 0
}
const newRedis = new Redis(redis)

function RedisGet(key) {
    return new Promise(function (resolve, reject) {
        newRedis.get(key, function (err, result) {
            if (err) reject(err)
            resolve(result);
        });
    })
};

//newRedis.set('a',"haha")
module.exports.newRedis = newRedis
module.exports.RedisGet = RedisGet

// async function test() {
//     let rows = await RedisGet('/list')
//     if (rows != null) {
//         console.log('rows = ', rows)
//         return;
//     }
//     let OuVersions = "OuVersions"
//     newRedis.set('/list', JSON.stringify({ Ou: OuVersions }))
// }

// test()